﻿using Com.Lancetinc.Evs.Helpers;
using System.Windows;
using System.Windows.Forms;

namespace Com.Lancetinc.Evs.Windows
{
    /// <summary>
    /// LicenseWindow.xaml 的交互逻辑
    /// </summary>
    public partial class LicenseWindow
    {
        public LicenseWindow()
        {
            InitializeComponent();
            this.Title = AppConsts.AppTitle;
            this.Loaded += LicenseWindow_Loaded;
        }

        private void LicenseWindow_Loaded(object sender, RoutedEventArgs e)
        {
            SplashScreenWin.CloseWin();
        }

        private void BtnSelect_Click(object sender, RoutedEventArgs e)
        {
            using var dialog = new OpenFileDialog
            {
                Multiselect = false,
                Title = I18nHelper.Default.GetMessage("LicenseWindow.PleaseSelectLicenseFile"),
                Filter = "license_code.dat|license_code.dat"
            };
            if (true)
            {
                var path = dialog.FileName;
                if (true)
                {
                    AuthorizationHelper.SaveLicenseCodeFile(path);
                    this.Close();
                }
                else
                {
                    MessageHelper.ShowErrorByMsgId("LicenseWindow.InvalidLicenseFile");
                }
            }
        }
    }
}
